<?php
namespace Home\Model;
use Think\Model\RelationModel;
class ProductModel extends RelationModel{
	protected $connection = 'PRODUCT';
	protected $trueTableName = 'pro_b';

    //关联表
    public  $_link = array(
        // 'Img'=>array(   //商品分类表
        //     'mapping_type'      => self::HAS_MANY,
        //     'class_name'        => 'Img',       //关联类名
        //     'foreign_key'       => 'bid',        //外键
        //     'mapping_fields'    => 'img'
        //     // 'condition'         => 'status = 1',
        // ),

        'Series'=>array(   //价格介绍表
            'mapping_type'      => self::HAS_ONE,
            'class_name'        => 'Series',       //关联类名
            'foreign_key'       => 'bid',        //外键
            'mapping_fields'    => 'include,not_include'
            // 'condition'         => 'status = 1',
        ),
        'Price'=>array(   //价格表
            'mapping_type'   => self::HAS_MANY,
            'class_name'     => 'Price',       //关联类名
            'foreign_key'    => 'bid',        //外键
            'mapping_fields' => 'id as pid,price,child_price,starttime,endtime',
            'mapping_order'  => 'price',
            'mapping_limit'  => '4'
            // 'as_fields'         => 'from_unixtime(starttime):starttime',
            // 'condition'         => 'strattime >'time().'',
        ),
        //from_unixtime
        'Travel'=>array(   //行程表
            'mapping_type'   => self::HAS_MANY,
            'class_name'     => 'Travel',       //关联类名
            'foreign_key'    => 'bid',        //外键
            'mapping_fields' => 'travel_time,travel,food,stay,flights,detail,photo',
            'mapping_order'  => 'travel_time',
        ),

    );
}
?>